package com.suray.system.run.seer.http.bean;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

@Data
public class SeerAgvTaskSend {

    @JsonProperty("id")
    private String id;
    @JsonProperty("priority")
    private Integer priority;
    @JsonProperty("deadline")
    private String deadline;
    @JsonProperty("vehicle")
    private String vehicle;
    @JsonProperty("tag")
    private String tag;
    @JsonProperty("group")
    private String group;
    @JsonProperty("candidates")
    private List<String> candidates;
    @JsonProperty("keyRoute")
    private List<String> keyRoute;
    @JsonProperty("blocks")
    private List<BlocksDTO> blocks;
    @JsonProperty("complete")
    private Boolean complete;

    @Data
    public static class BlocksDTO {
        @JsonProperty("blockId")
        private String blockId;
        @JsonProperty("location")
        private String location;
        @JsonProperty("operation")
        private String operation;
        @JsonProperty("script_name")
        private String scriptName;
        @JsonProperty("script_args")
        private ScriptArgsDTO scriptArgs;

        public BlocksDTO(String blockId, String location, String operation) {
            this.blockId = blockId;
            this.location = location;
            this.operation = operation;
        }

        @NoArgsConstructor
        @Data
        public static class ScriptArgsDTO {
        }
    }

    public SeerAgvTaskSend(String id) {
        this.id = id;
        blocks = new ArrayList<>();
    }

    /**
     * 添加动作块
     * @param blockId
     * @param location
     * @param operation
     */
    public void addBlock(String blockId, String location, String operation) {
        blocks.add(new BlocksDTO(blockId, location, operation));
    }
}
